
<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>作业管理</title>

<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->	

</head>

<body>
<div class="button">
		<a class="easyui-linkbutton" id="addhomework" iconCls="icon-add">布置作业</a> <a
			class="easyui-linkbutton" id='cuthomework' iconCls="icon-cut">删除作业</a>

		作业状态：<select id="status">
			<option value="all">全部</option>
			<option value="already">已完成</option>
			<option value="unalready">未完成</option>
			
		</select> <input type="submit" id='searchwork' value="搜索" />
	</div>
	
	<div id="Ioerdered" class="easyui-panel" title="我布置的作业" iconCls="icon-edit" 
	closable="false" collapsible="true" minimizable="false" maximizable=false >
	
	<form >
		<input type="hidden" name="action" value="delete" />
		<table class="Ioerderedhomework" cellpadding="0" cellspacing="0">
		</table>
	</form>
	<div id="dd"></div>
	<div id="aa"></div>
</div>
<br><br>
	<div id="others" class="easyui-panel" title="组长布置的作业：" 
			iconCls="icon-edit"  closable="false"
			collapsible="true" minimizable="false" maximizable=false>
		
<form >
		<input type="hidden" name="action" value="delete" />
		<table class="othershomework" cellpadding="0" cellspacing="0">
		</table>
	</form>

	</div>

	<script type="text/javascript">
		$(document).ready(function() {			
	
         $('.Ioerderedhomework').datagrid({
 	url:'homework_manage/teacher/queryself.jsp',
	pagination:true,
	rownumbers:true,
	pageSize:5,
	pageList:[5,10,15],
	columns:[[
			{field:'taskid',title:'作业编号',width:70},
			{field:'name',title:'作业接收者',width:100},
			{field:'taskname',title:'作业名称',width:160},
			{field:'status',title:'作业进度',width:100},										
			{field:'detail',title:'作业详情',width:80
			},
			{field:'endtime',title:'截止时间',width:100},
			{field:'isappend',title:'有无附件',width:60},
			   //里面显示    更改 
			{field:'cut',checkbox:true },
		]],
		onClickCell:function(rowIndex, field, value){
				 
       
		$(this).click(function(){
				
		$(this).css("color","red");
		$('#dd').dialog({
			  onClose:function(){
				$("td").css("color","black");  
			  }
		});
		
		
		})
		if(field=='detail'){
		
        var rows = $('.Ioerderedhomework').datagrid('getSelections');        
		if (!rows || rows.length == 0) {
         alert("没有选上数据!");}  
         var id=rows[0].taskid;
     
			   
			 $('#dd').dialog({
		         title:"作业详情",
				 zIndex:9001,
				 width:700, height:500,
				 top:150,left:400,
				 cache:false,
				 resizable:true,
				href:'homework_manage/teacher/work_detail.jsp?id='+id//！！！！后台请注意获取的时候检测一下
		   });
		   
		        $('#dd').dialog('refresh', 'homework_manage/teacher/work_detail.jsp?id='+id);
			}
		
		
		}
		
		
           })
           
           
           
			//alert("dhsgfhadghgj");
			/*添加处理*/

			$("#addhomework").click(function() {
			$('#dd').dialog({
			         title:"发布作业",
					  zIndex:9001,
					 width:680, height:400,
					 top:150,left:300,
					 cache:false,
					 href:'homework_manage/add_homwork.jsp' 
					 });
				$('#dd').dialog('refresh', 'homework_manage/add_homwork.jsp' );
					 
					 
			/*	var tab = $(".easyui-tabs").tabs('getSelected');
			 		$(".easyui-tabs").tabs('update',
			                        {tab:tab,
									 options:{
								     cache:false,
                                     href:'homework_manage/teacher/homework_manage.jsp',
									 }
									}
									);  /*更新面板*/	
	    })	;
	    
	   $("#cuthomework").click(function(){
	  	 var ids=[];
        var rows = $('.Ioerderedhomework').datagrid('getSelections'); 
        var rows2 = $('.othershomework').datagrid('getSelections');
		if ((!rows || rows.length == 0)&&(!rows2 || rows2.length == 0)) {
         $.messager.alert('提示', '请选择要删除的数据!', 'info');return;}  
      $.each(rows, function (i, n) {
     ids.push(n.taskid);
});

$.each(rows2, function (i, n) {
     ids.push(n.taskid);
});
$.messager.confirm('提示', '是否删除选中数据?', function (r) {
if (!r) {
return;
} 
//alert(ids);
$.ajax({
		   url:'homework_manage/teacher/deletehomework.jsp',       /*删除处理界面,传到后台的是所有选中的行号组成的数字数组*/
		   data:'selectrows='+ids,
		   dataType:'text',
		   success:function(msg){
			   if(msg=='ok'){
				   alert("删除成功");
			 	  	var tab = $(".easyui-tabs").tabs('getSelected');
			 		$(".easyui-tabs").tabs('update',
			                        {tab:tab,
									 options:{
								     cache:false,
                                     href:'homework_manage/teacher/homework_manage.jsp',
									 }
									}
									);  /*更新面板*/

				   } 
          		else{
					alert("删除失败");
					}
				}
			  
		   })

		  })
		  //alert("hello");
	});
	  
	 /*搜索处理*/
$("#searchwork").click(function(){
   var status = $("#status").val();
   //alert(status);
  $('.Ioerderedhomework').datagrid('load',{"status":status});
 $('.othershomework').datagrid('load',{"status":status});
  /*更新面板*/	
		
	})
	  
	  
	  
	  
	  
	  $('.othershomework').datagrid({
 	url:'homework_manage/teacher/queryall.jsp',
	pagination:true,
	rownumbers:true,
	pageSize:5,
	pageList:[5,10,15],
	columns:[[
			{field:'taskid',title:'作业编号',width:70},
			{field:'fromname',title:'作业布置者',width:80},
			{field:'name',title:'作业接收者',width:80},
			{field:'taskname',title:'作业名称',width:140},
			{field:'status',title:'作业进度',width:100},										
			{field:'detail',title:'作业详情',width:80
			},
			{field:'endtime',title:'截止时间',width:100},
			{field:'isappend',title:'有无附件',width:70},
			   //里面显示    更改 
			{field:'cut',checkbox:true },
		]],
		onClickCell:function(rowIndex, field, value){
				 
       
		$(this).click(function(){
				
		$(this).css("color","red");
		$('#dd').dialog({
			  onClose:function(){
				$("td").css("color","black");  
			  }
		});
		
		
		})
		if(field=='detail'){
		
        var rows = $('.othershomework').datagrid('getSelections');        
		if (!rows || rows.length == 0) {
         alert("没有选上数据!");}  
         var id=rows[0].taskid;
     
			   
			 $('#dd').dialog({
		         title:"作业详情",
				 zIndex:9001,
				 width:700, height:500,
				 top:150,left:400,
				 cache:false,
				 resizable:true,
				href:'homework_manage/teacher/work_detail.jsp?id='+id//！！！！后台请注意获取的时候检测一下
		   });
		   
		   $('#dd').dialog('refresh', 'homework_manage/teacher/work_detail.jsp?id='+id );
		   
		  
			}
		
		
		}
		
		
           })
           
	    	
		})
	</script>
</body>
</html>

